package com.atguigu.activemq.queue_redelivery;

import org.apache.activemq.ActiveMQConnectionFactory;

import javax.jms.*;


public class JmsProduce {
    public static final String ACTIVEMQ_URL="tcp://124.70.84.192:61616";
    public static final String QUEUE_NAME="queue_redelivery";
    public static void main(String[] args) throws JMSException {
        ActiveMQConnectionFactory activeMQConnectionFactory=new ActiveMQConnectionFactory(ACTIVEMQ_URL);
        Connection connection = activeMQConnectionFactory.createConnection();
        connection.start();
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Queue queue = session.createQueue(QUEUE_NAME);
        MessageProducer messageProducer = session.createProducer(queue);
        messageProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
        for (int i=1;i<4;i++){
            TextMessage textMessage = session.createTextMessage("我发送的第" + i + "条消息");
            textMessage.setStringProperty("c01","vip");
            textMessage.setIntProperty("vip",8);
            textMessage.setBooleanProperty("vip8",true);
            messageProducer.send(textMessage);
        }
        messageProducer.close();
        session.close();
        connection.close();
        System.out.println("连接中断");
    }
}
